Skip to content

ncps - expand inline guest #2356

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 13, 2024
Merged

ncps - expand inline guest #2356

merged 4 commits into from
Mar 13, 2024

Conversation

jshawl
Copy link
Contributor

@jshawl jshawl commented Mar 7, 2024

Description

This PR is a partial revert of #2320, specifically: inline guest no longer opens a popup by default for ncps flows, but expands inline and redirects to a thank you page after onApprove is invoked.

Why are we making these changes?

There is an open incident regarding the discrepancy between inline guest expanding vs popup. Let me know if you'd like more info and I can point you in the right direction.

Reproduction Steps (if applicable)

Complete a checkout with a hosted button using inline guest. You should see inline guest expand inline, and redirect to a thank you page after the order is approved and captured.

Dependent Changes (if applicable)

  • There is server side (2 separate components) logic that this code depends on

❤️ Thank you!

Copy link

codecov bot commented Mar 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 58.03%. Comparing base (648b54d) to head (dda07c2).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2356      +/-   ##
==========================================
+ Coverage   58.00%   58.03%   +0.03%     
==========================================
  Files         153      153              
  Lines       12232    12241       +9     
  Branches      742      745       +3     
==========================================
+ Hits         7095     7104       +9     
  Misses       5041     5041              
  Partials       96       96              
Flag Coverage Δ
jest 32.12% <ø> (ø)
karma 50.17% <ø> (ø)
vitest 54.28% <100.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jshawl jshawl marked this pull request as ready for review March 7, 2024 21:25
@jshawl jshawl requested a review from a team as a code owner March 7, 2024 21:25
@@ -208,6 +209,14 @@ export const buildHostedButtonOnApprove = ({
merchant_id: merchantId,
context_id: data.orderID,
}),
}).then((response) => {
// The "Debit or Credit Card" button does not open a popup
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does sometimes open a popup though right? or are we saying in the ncps case it ALWAYS does the expand?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it does sometimes open a popup - e.g. clicking on the debit or credit card button before second render. I tested this scenario and made sure a second popup isn't opened though it's not obvious to me just yet why that isn't a bug 🤔

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it redirect inside the popup instead of the parent page?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no it closes the popup and then full page redirects from the merchant site to the thank you page

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh wow, so this handles both cases. That's great!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes! though I think what's happening under the hood is that this window.location = is forcing the popup to close in the beforeUnload event. Similar to:

  1. Click on paypal button (popup opens)
  2. open dev console and window.location = 'https://example.com/'
  3. Observe popup close

I think this is an OK tradeoff but wanted to be transparent about why this "works". An alternative would be only invoking window.location= if the popup window wasn't opened because of a prerender click (not sure what's involved in that but I bet it will be challenging / complex)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would there be enough time to close it through onApprove?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely! But I think the correct way would be to not close the popup - e.g. redirect from within the popup to the thank you page (identical to the PayPal button functionality)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

e.g. I don't think there's a way to know that onApprove was invoked from a prerender-click context: I'll timebox it early next week and see if it's a quick win but otherwise I think we should go with what's in this PR - wdyt? I'm def open to other ideas

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm down for the bare minimum that matches what product is asking for. Whatever that is lol but feel free to do as much exploration as you want

@jshawl jshawl merged commit 82af8b4 into main Mar 13, 2024
@jshawl jshawl deleted the ncps-inline-guest branch March 13, 2024 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants